home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Computers
/
Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso
/
shareware
/
fractals
/
fracblank
/
fracblank.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-17
|
62KB
|
3,047 lines
/*
** FracBlank - AmigaDOS 2.04 commodities utility screenblanker
**
** Copyright © 1991-1992 by Olaf `Olsen' Barthel
** All Rights Reserved
**
** Cosmic flame fractal code derived from xlock source code
**
** Copyright © 1988-1991 by Patrick J. Naughton.
*/
/* Include the specific math pragmas/header files here (is there
* any way to figure this out by taking a look at undocumented
* predefined compiler symbols?).
*/
#ifdef MATH_FFP
#include <clib/mathtrans_protos.h>
#include <proto/mathtrans.h>
#include <mffp.h>
#else
#include <m68881.h>
#endif /* MATH_FFP */
#include <math.h>
/* sin -45° = cos -45° (saves precious calculation time). */
#define deg45 (-0.707106781)
/* Use a simple address trick instead of the predefined
* address in amiga.lib.
*/
#ifndef custom
#define custom (*(struct Custom *)0xDFF000)
#endif /* custom */
/* A couple of handy gadget control macros. */
#define GT_CHECKED(G) ((((struct Gadget *)(G)) -> Flags & GFLG_SELECTED) ? TRUE : FALSE)
#define GT_STRING(G) (((struct StringInfo *)(((struct Gadget *)(G)) -> SpecialInfo)) -> Buffer)
/* Hotkey IDs. */
enum { POP_WINDOW,BLANK_SCREEN };
/* Gadget IDs. */
enum { GAD_SCREENTIMEOUT,GAD_MOUSETIMEOUT,GAD_PATTERNCHANGE,GAD_HOTKEY,
GAD_BLANKSCREEN,GAD_KEYBLANK,GAD_FRACTAL,GAD_COLOUR,GAD_HIDE,GAD_QUIT };
/* Some useful signals. */
#define SIG_BREAK SIGBREAKF_CTRL_C
#define SIG_CHANGE SIGBREAKF_CTRL_D
#define SIG_CYCLE SIGBREAKF_CTRL_E
#define SIG_START SIGBREAKF_CTRL_F
#define SIG_REFRESH SIGBREAKF_CTRL_E
#define SIG_WAKEUP SIGBREAKF_CTRL_F
#define SIG_CX (1 << CxPort -> mp_SigBit)
#define SIG_WINDOW (Window ? (1 << Window -> UserPort -> mp_SigBit) : NULL)
/* Private mouse blanker signals. */
#define SIG_NOTICE SIGBREAKF_CTRL_D
#define SIG_ON SIGBREAKF_CTRL_E
#define SIG_OFF SIGBREAKF_CTRL_F
/* Number of patches to install. */
#define NUM_PATCHES (sizeof(PatchTable) / sizeof(struct PatchInfo))
/* Cosmic flame fractal parameters. */
#define MAXFLAMELEVEL 20
#define MAXTOTALPOINTS 20000
/* Fractal types. */
enum { FRACTAL_REAL_PLANE,FRACTAL_COSMIC_FLAME,FRACTAL_RANDOM };
/* Colour modes. */
enum { COLOUR_CYCLE,COLOUR_STATIC,COLOUR_MONO };
/* A system library patch definition. */
struct PatchInfo
{
APTR NewRoutine;
LONG Offset;
ULONG *Destination;
};
/* A window identification node, also contains information
* on the currently selected pointer sprite.
*/
struct WindowNode
{
struct MinNode Node;
struct Window *Window;
UWORD *Pointer;
BYTE Height,
Width;
BYTE XOffset,
YOffset;
BYTE Off;
};
/* The offsets of the system library routines we will patch. */
extern ULONG __far LVOClearPointer,
LVOSetPointer,
LVOOpenWindow,
LVOOpenWindowTagList,
LVOCloseWindow;
/* Program revision tag. */
STATIC const UBYTE VersTag[] = "\0$VER: FracBlank 2.2 (4.4.92)";
/* Shared library identifiers. */
extern struct ExecBase *SysBase;
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct Library *CxBase,
*IconBase,
*GadToolsBase,
*UtilityBase;
/* The main program. */
struct Process *MainProcess;
/* Blanker data. */
struct Task *BlankTask;
struct Screen *BlankScreen;
/* BlankerControl data. */
struct Task *BlankerControlTask;
/* Mouse blanker data. */
struct Task *MouseBlankerTask;
/* Commodities interface data. */
struct MsgPort *CxPort;
CxObj *Broker;
/* Gfx and gadtools data. */
struct Screen *DefaultScreen;
APTR VisualInfo;
struct TextFont *LocalFont;
struct Gadget *GadgetList;
struct Gadget *GadgetArray[GAD_QUIT + 1];
struct Window *Window;
/* Window zoom data. */
struct IBox ZoomData = { -1,-1,-1,-1 };
/* Window dimensions. */
WORD WindowWidth = 284,
WindowHeight = 113;
/* Rainbow colour table. */
UWORD Table[75];
/* No colours at all. */
UWORD Black[32];
/* Declarations for cosmic flame blanker code. */
float Flame[2][3][2];
WORD FlameLevel,
FlameAlternateForm,
FlameModulo;
UWORD FlameColourTable[32];
BYTE FlameWheel,
FlameColour;
PLANEPTR FlamePlane;
ULONG FlamePoints;
/* Key sequence buffers. */
UBYTE HotkeyBuffer[256],
BlankScreenBuffer[256];
/* Screen and pattern change timeout. */
ULONG ScreenCount = 0,
PatternCount = 0,
ScreenTimeout = 60,
MouseTimeout = 5,
PatternTimeout = 60;
/* A flag which tells us whether to blank the mouse pointer
* on a keypress or not.
*/
BYTE KeyBlank = TRUE;
/* Some kind of a semaphore to tell the blank task to stop drawing. */
BYTE StopDrawing = FALSE;
/* The default font to be used by the control panel. */
struct TextAttr DefaultFont;
UBYTE DefaultFontName[256];
UWORD DefaultFontWidth;
/* The colours of a rainbow (well, with a bit of imagination, just
* 32 colours in this rainbow for now).
*/
UWORD Rainbow[32] =
{
0x0000,0x0F00,0x0F30,0x0F50,
0x0F70,0x0F90,0x0FB0,0x0FD0,
0x0FF0,0x0DF0,0x0BF0,0x09F0,
0x07F0,0x05F0,0x03F0,0x00F0,
0x00D1,0x00B3,0x0095,0x0077,
0x0059,0x003B,0x001D,0x000F,
0x010F,0x030F,0x050F,0x070F,
0x090F,0x0B0F,0x0D0F,0x0F0F
};
/* A new broker definition, Commodities needs this. */
struct NewBroker NewBroker =
{
NB_VERSION,
"FracBlanker",
"Fractal Blanker v2.2",
"Screen Blanker",
NBU_NOTIFY | NBU_UNIQUE,
COF_SHOW_HIDE,
0,NULL,0
};
/* The fractal mode names. */
STRPTR FractalModes[] =
{
"Real Plane",
"Cosmic Flame",
"Random",
NULL
};
/* The current fractal type. */
UBYTE FractalType = FRACTAL_RANDOM;
/* The colour mode names. */
STRPTR ColourModes[] =
{
"Cycling Colours",
"Static Colours",
"Monochrome",
NULL
};
/* The current colour mode. */
UBYTE ColourMode = COLOUR_CYCLE;
/* Patch data. */
extern VOID __stdargs StackOldSetPointer(struct Window *Window,UWORD *Pointer,WORD Height,WORD Width,WORD XOffset,WORD YOffset);
extern VOID NewSetPointer(VOID);
APTR OldSetPointer;
VOID (* __asm OldClearPointer)(register __a0 struct Window *,register __a6 struct IntuitionBase *);
struct Window * (* __asm OldOpenWindowTagList)(register __a0 struct NewWindow *,register __a1 struct TagItem *,register __a6 struct IntuitionBase *);
struct Window * (* __asm OldOpenWindow)(register __a0 struct NewWindow *,register __a6 struct IntuitionBase *);
VOID (* __asm OldCloseWindow)(register __a0 struct Window *,register __a6 struct IntuitionBase *);
/* Mouse blanker function prototypes. */
VOID __stdargs __saveds StackNewSetPointer(struct Window *Window,UWORD *Pointer,WORD Height,WORD Width,WORD XOffset,WORD YOffset);
VOID __asm __saveds NewClearPointer(register __a0 struct Window *Window);
struct Window * __asm __saveds NewOpenWindowTagList(register __a0 struct NewWindow *NewWindow,register __a1 struct TagItem *TagList);
struct Window * __asm __saveds NewOpenWindow(register __a0 struct NewWindow *NewWindow);
VOID __asm __saveds NewCloseWindow(register __a0 struct Window *Window);
VOID __saveds MouseBlanker(VOID);
VOID __regargs UpdateNode(struct WindowNode *Node,struct Window *Window);
struct WindowNode * __regargs NewNode(struct Window *Window);
VOID TurnOff(VOID);
VOID TurnOn(VOID);
/* The window and mouse pointer access list. */
struct SignalSemaphore WindowSemaphore;
struct List WindowList;
/* Miscellaneous mouse blanker counters and flags. */
ULONG KeyBlankUseCnt = 0,
KeyBlankCount = 0;
BYTE AllSpritesOff = FALSE,
KeyBlankStop = FALSE;
/* The table of patches to install. */
struct PatchInfo PatchTable[] =
{
NewClearPointer, (LONG)&LVOClearPointer, (ULONG *)&OldClearPointer,
NewSetPointer, (LONG)&LVOSetPointer, (ULONG *)&OldSetPointer,
NewOpenWindowTagList, (LONG)&LVOOpenWindowTagList, (ULONG *)&OldOpenWindowTagList,
NewOpenWindow, (LONG)&LVOOpenWindow, (ULONG *)&OldOpenWindow,
NewCloseWindow, (LONG)&LVOCloseWindow, (ULONG *)&OldCloseWindow
};
/* An entirely transparent sprite. */
UWORD __chip BlankSprite[(2 + 1) * 2] =
{
0x0000,0x0000,
0x0000,0x0000,
0x0000,0x0000
};
/* Function prototypes. */
extern VOID __asm MonoPlot(register __a0 PLANEPTR Plane,register __d0 WORD x,register __d1 WORD y,register __d2 UWORD Modulo,register __d3 WORD